//
// Created by francklinson on 2022/1/1 AT 14:34.
//
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;

class Solution {
public:
    int countWords(vector<string> &words1, vector<string> &words2) {
        unordered_map<string, int> counter1,counter2;
        for (string &x:words1) {
            ++counter1[x];
        }
        for (string &x:words2) {
            ++counter2[x];
        }
        int ans = 0;
        for (auto &p:counter1) {
            if (p.second == 1 && counter2[p.first] == 1)
                ++ans;
        }
        return ans;
    }
};

int main() {
    vector<string> words1{"leetcode", "is", "amazing", "as", "is"};
    vector<string> words2{"amazing", "leetcode", "is"};
    Solution solution;
    cout << solution.countWords(words1, words2) << endl;
    return 0;
}

